package cn.tedu.pojo.mvc;

import org.junit.Test;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

//http://localhost:8080/car/insert?id=1&name=张三&age=18

//Springmvc解析get请求参数
@RestController//接受请求作出响应
@RequestMapping("get")//规定了浏览器的访问方式
public class GetController {
    @RequestMapping("param1")
    public Car param1(Car c){
        return c;
    }
    @RequestMapping("param")
    public String param(int id, String name, int age){
        return "id="+id+",name="+name+",age="+age;
    }
    @Test//单元测试方法
    public void get1(){
        String url ="http://localhost:8080/car/insert?id=1&name=张三&age=18";
        String[] a = url.split("\\?")[1].split("&");
        for(String s:a){
            String data = s.split("=")[1];
            System.out.println(data);
        }
    }
}
